<template>
  <div class="materialManagementCont">
    <Button type="primary" class="aciton" style="margin-left:10px; z-index:999;"> <a
        href="https://images.tospurfang.com/doc/%E6%96%87%E7%AB%A0%E5%AE%A1%E6%A0%B8%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E.pdf"
        style="color:#fff;" target="_blank">查看操作指引</a>
    </Button>
    <Tabs type="card" :value="tabName" @on-click="tabChange">
      <TabPane label="待审核" name="0"></TabPane>
      <TabPane label="已通过" name="1"></TabPane>
      <TabPane label="已驳回" name="2"></TabPane>
    </Tabs>

    <dt-grid ref="table" :columns="columns" page :onFetch='onFetch' />
    <!--流程信息-->
    <process-modal ref="process" />
  </div>
</template>
<script>
  import infoMgr from '@/biz/base/info'
  import Helper from '@/common/helper.js'
  import columnsAll from './columns'
  import articleMgr from '@/biz/article/article.js'
  import processModal from '@/components/biz/audit/process-modal.vue'
  import auditMgr from '@/biz/flowApproval/processAudit.js'
  export default {
    components: {
      processModal
    },
    data() {
      return {
        tabName: '0',
        loading: false,
        auditStatusList: ['-', '已通过', '已驳回', '待审核'],
        columns: [],
        instanceId:null
      }
    },
    methods: {
      // 跳转文章详情
      labelTypeClick(val) {
        articleMgr.articleDetail({ articleId: val.businessId }).then((res) => {
          if (res) {
            this.$router.push({
              path: '/marketingCenter/propertyReport/articleManagement/viewArticlePage',
              query: { type: 'view', articleId: val.businessId },
            })
          }else{
            this.$Message.info('该文章已删除')
          }
        }).catch((err) => {
        })
      },

      processFun(data) {
        this.$refs.process.show({
          businessId: data.businessId,
          auditType: 13
        })
      },

      tabChange(val) {
        this.instanceId = null
        this.tabName = val
        this.columns = columnsAll.options(this)
        this.$refs.table.fetch()
      },

      onFetch(data) {
        return auditMgr.list({
          ...data,
          auditType: 13,
          buttonType: this.tabName,
          housesId:this.$dt.buildInfo().housesId,
          instanceId:this.instanceId
        }).then(res => {
          res && res.list.forEach(item => {
            item = Object.assign(item, item.auditData)
          })
          return res
        })
      },

      // 审核 重新审核
      reviewFun(rows) {
        this.$router.push({
          path: '/marketingCenter/propertyReport/articleReview/viewArticleReview',
          query: { articleId: rows.businessId,auditId:rows.auditId },
        })
      },
      // 查看原因
      viewReason(row) {
        this.$Modal.info({
          title: '驳回原因',
          content: row.auditReason || '-',
          okText: '关闭',
        })
      }
    },

    created() {
    },
    mounted() {
      this.instanceId = this.$route.params.businessId
      this.tabName = this.$route.params.tabCheck || '0'
      this.columns = columnsAll.options(this)
      this.$refs.table.init(this)
      this.$refs.table.fetch()
    },

  }
</script>
<style lang="scss" scoped>
  .materialManagementCont {
    padding-top: 10px;
    position: relative;

    .aciton {
      position: absolute;
      top: 5px;
      right: 10px;
    }
  }
</style>